<?php
/**
 * +----------------------------------------------------------------------
 * | summer framework
 * +----------------------------------------------------------------------
 * | Copyright (c) 2020 https://github.com/suframe/think-admin All rights reserved.
 * +----------------------------------------------------------------------
 * | Author: summer <806115620@qq.com>  2020/3/30 14:30
 * +----------------------------------------------------------------------
 */
declare (strict_types = 1);

namespace app\mall\model\traits;

use app\mall\enum\StockTypeEnum;
use think\Model;

/**
 * 商品库存类型
 * trait GoodsStockTypeTrait
 * @package app\mall\model\traits
 * @property string stock_type
 * @mixin Model
 */
trait GoodsStockTypeTrait
{

    /**
     * 库存类型名称
     * @return string
     */
    public function getStockTypeTextAttr(): string
    {
        return $this->getStockEnumAttr()->getZhName();
    }

    public function getStockEnumAttr()
    {
        return new StockTypeEnum($this->stock_type);
    }
}